package easy;

import java.util.stream.IntStream;

/**
 * @author admin
 * 1480. 一维数组的动态和
 * 思路：当前数等于前两个数之和
 */
public class LeeCode1480 {


    public int[] runningSum(int[] nums) {

        for (int i = 1; i < nums.length; i++) {
            nums[i] = nums[i] + nums[i-1];
        }
        return nums;
    }

    public static void main(String[] args) {
        new LeeCode1480().runningSum(new int[]{1,1,1,1,1});
        /*

        {1,2,3,4,5}
        i=1   nums[1] = nums[1] + nums[0] = 1 + 1 = 2
        i=2   nums[2] = nums[2] + nums[1] = 1 + 2 = 3
        i=3   nums[3] = nums[3] + nums[2] = 1 + 3 = 4
        i=4   nums[4] = nums[4] + nums[3] = 1 + 4 = 5
         */
    }
}
